/**
 * 
 */
package com.zhang.junit;

import java.io.InputStream;
import java.util.Iterator;
import java.util.List;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import com.zhang.mappers.oradeMapper;
import com.zhang.pojo.Orders;
import com.zhang.pojo.User;

/**
 * @张博皓
 *2017年11月17日
 */
public class CopyOfmapperTest2 {

	@Test
	public void testMapperOrdeerList() throws Exception {
	String resource ="sqlMapConfig.xml";
	//加载核心配置文件
	InputStream in= Resources.getResourceAsStream(resource);
	//创建sqlsession工厂
	SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(in);
	//创建sqlsession
	SqlSession sqlsession = sqlSessionFactory.openSession();
	oradeMapper mapper = sqlsession.getMapper(oradeMapper.class);;
	List<Orders> selectOrdersList = mapper.selectOrdersList();
for (Orders orders : selectOrdersList) {
	System.out.println(orders);
}
	}
	
	//一对多映射
	@Test
	public void testMapperlistuser() throws Exception {
	String resource ="sqlMapConfig.xml";
	//加载核心配置文件
	InputStream in= Resources.getResourceAsStream(resource);
	//创建sqlsession工厂
	SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(in);
	//创建sqlsession
	SqlSession sqlsession = sqlSessionFactory.openSession();
	oradeMapper mapper = sqlsession.getMapper(oradeMapper.class);;
	List<User> selectOrdersList = mapper.Selectlistuser();
	for (User user : selectOrdersList) {
		System.out.println(user);
	}
	}
	
}